home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWViews / FWContrH.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  8.1 KB  |  254 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWContrH.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #if    defined(FW_BUILD_MAC) && !defined(FWCONTRH_H)
  11. #define FWCONTRH_H
  12.  
  13. // ----- OS Layer -----
  14.  
  15. #ifndef FWRECT_H
  16. #include "FWRect.h"
  17. #endif
  18.  
  19. // ----- Macintosh Includes -----
  20.  
  21. #if defined(FW_BUILD_MAC) && !defined(__CONTROLS__)
  22. #include <Controls.h>
  23. #endif
  24.  
  25. //========================================================================================
  26. // Forward declarations
  27. //========================================================================================
  28.  
  29. class    FW_CNativeControl;
  30. class     FW_CFont;
  31. class    FW_CScrollBar;
  32. class   FW_CPopupMenu;
  33. class    FW_CString;
  34. class    FW_SPrivControlOwner;
  35. class     ODFacet;
  36. class     FW_CAcquireCFMResourceAccess;
  37. class    FW_CViewContext;
  38.  
  39. //========================================================================================
  40. //    CLASS FW_CPrivMacGrayishTextProc
  41. //========================================================================================
  42.  
  43. class FW_CPrivMacGrayishTextProc
  44. {
  45. public:
  46.     FW_DECLARE_AUTO(FW_CPrivMacGrayishTextProc)
  47.     
  48.     FW_CPrivMacGrayishTextProc(GrafPtr thePort);
  49.     ~FW_CPrivMacGrayishTextProc();
  50.     
  51. private:
  52.         // private, unimplemented copy constructor and assignment operator
  53.     FW_CPrivMacGrayishTextProc(const FW_CPrivMacGrayishTextProc& other);
  54.     FW_CPrivMacGrayishTextProc& operator=(const FW_CPrivMacGrayishTextProc& other);
  55.     
  56. private:
  57.     
  58.     static pascal void TextProcCallback(short byteCount, Ptr textBuf, Point numer, Point denom);
  59.     
  60. private:
  61.     GrafPtr     fPort;
  62.     FW_Boolean     fIsColorPort;
  63.     FW_Boolean    fQDProcsCreated;
  64.     QDProcs        fQDProcs;        // uses one or the other
  65.     CQDProcs    fCQDProcs;
  66.     QDTextUPP    fNewTextProcUPP;
  67.     
  68.     static QDTextUPP fgOldTextProcUPP;
  69. };
  70.  
  71. //========================================================================================
  72. //    CLASS FW_CPrivMacControlHelper
  73. //========================================================================================
  74.  
  75. class FW_CPrivMacControlHelper
  76. {
  77. public:
  78. //    FW_DECLARE_CLASS
  79.  
  80. // ----- Initialization/destruction
  81. public:
  82.     FW_CPrivMacControlHelper(Environment* ev, FW_CNativeControl* control,
  83.                                     short value, short min, 
  84.                                     short max, short procID,
  85.                                     const Str255 label,
  86.                                     const FW_CFont& font,
  87.                                     long refCon = 0);
  88.     virtual     ~FW_CPrivMacControlHelper();
  89.     
  90. public:
  91.     ControlHandle            GetControlHandle() const;
  92.                                     
  93.     void                    SetControlMargin(short margin);
  94.     
  95.     void                    SetBounds(const FW_CPlatformRect& controlBounds);
  96.     void                    GetBounds(FW_CPlatformRect& controlBounds) const;
  97.         
  98.     void                    SetValue(short value, 
  99.                                      const FW_CPlatformPoint& location,
  100.                                      const FW_CPlatformPoint& size);
  101.     void                    SetValue(short value, FW_Boolean drawNow);
  102.     short                    GetValue() const;
  103.     void                    SetMin(short min);
  104.     short                    GetMin() const;
  105.     void                    SetMax(short max);
  106.     short                    GetMax() const;
  107.     void                    SetText(const FW_CString& text);
  108.     void                    GetText(FW_CString& text) const;
  109.     
  110.     FW_CFont                GetFont(Environment* ev) const;
  111.  
  112.     FW_CNativeControl*        GetControl() const;
  113.  
  114.     void                    Draw(Environment* ev,
  115.                                     ODFacet* facet, 
  116.                                     const FW_CPlatformPoint& location,
  117.                                     const FW_CPlatformPoint& size);
  118.     void                     Print(Environment* ev, ODFacet* facet, 
  119.                                     const FW_CPlatformPoint& location,
  120.                                     const FW_CPlatformPoint& size);
  121.     void                     Enable(FW_Boolean enabled, const FW_CPlatformPoint& location,
  122.                                     const FW_CPlatformPoint& size);
  123.     void                     Enable(FW_Boolean enabled);
  124.     void                     Show(const FW_CPlatformPoint& location,
  125.                                     const FW_CPlatformPoint& size);
  126.     void                     Show();
  127.     void                     Hide();
  128.     Boolean                    MouseDown(Environment* ev, const FW_CViewContext& vc,
  129.                                     const FW_CPlatformPoint& whereMouse);
  130.     void                     SimulateButtonPressed(const FW_CPlatformPoint& location,
  131.                                     const FW_CPlatformPoint& size);
  132.  
  133.     virtual FW_Boolean         PartCodeSwitch(Environment* ev, 
  134.                                             const FW_CViewContext& vc,
  135.                                             const FW_CPlatformPoint& whereMouse, 
  136.                                             short partCode);
  137.  
  138. private:
  139.     void                    Initialize(Environment* ev, short value, short min, short max, 
  140.                                     const Str255 label, const FW_CFont& font, long refCon);
  141.  
  142.     void                     DrawControl(Environment* ev, ODFacet* facet);
  143.     void                    SetupControl(const FW_CPlatformPoint& location,
  144.                                          const FW_CPlatformPoint& size);
  145.  
  146.     FW_CAcquireCFMResourceAccess* OpenResFileForPopup(Environment* ev);
  147.  
  148. protected:
  149.     FW_CNativeControl*        fControl;    
  150.     ControlHandle            fControlHandle;        // Mac control
  151.     short                    fControlMargin;        // Used for drawing default button
  152.     short                    fMacProcID;    
  153.     short                    fMacFontID;            // = 0 if controls uses default font
  154.     short                    fMacFontStyle;    
  155.     short                    fMacFontSize;        
  156. };
  157.  
  158. //========================================================================================
  159. //    CLASS FW_CPrivMacScrollBarControlHelper
  160. //========================================================================================
  161.  
  162. class FW_CPrivMacScrollBarControlHelper : public FW_CPrivMacControlHelper
  163. {
  164. public:
  165.     FW_CPrivMacScrollBarControlHelper(Environment* ev, 
  166.                                     FW_CNativeControl* control,
  167.                                     short value, 
  168.                                     short min, 
  169.                                     short max, 
  170.                                     long refCon = 0);
  171.     virtual ~FW_CPrivMacScrollBarControlHelper();
  172.  
  173.     virtual FW_Boolean         PartCodeSwitch(Environment* ev, 
  174.                                         const FW_CViewContext& vc,
  175.                                         const FW_CPlatformPoint& whereMouse, 
  176.                                         short partCode);
  177.  
  178. private:
  179.     static pascal void        CallActionProc(ControlHandle controlHandle,  short partCode);
  180.     void                    ActionProc(short partCode);    
  181.     
  182. private:
  183.     ODFacet*        fFacet;
  184. };
  185.  
  186. //========================================================================================
  187. //    Inlines
  188. //========================================================================================
  189.  
  190. //----------------------------------------------------------------------------------------
  191. // FW_CPrivMacControlHelper::GetControlHandle
  192. //----------------------------------------------------------------------------------------
  193.  
  194. inline ControlHandle FW_CPrivMacControlHelper::GetControlHandle() const
  195. {
  196.     return fControlHandle;
  197. }
  198.  
  199. //----------------------------------------------------------------------------------------
  200. // FW_CPrivMacControlHelper::GetBounds
  201. //----------------------------------------------------------------------------------------
  202.  
  203. inline void FW_CPrivMacControlHelper::GetBounds(FW_CPlatformRect& controlBounds) const
  204. {
  205.     controlBounds = (*fControlHandle)->contrlRect;
  206. }
  207.  
  208. //----------------------------------------------------------------------------------------
  209. // FW_CPrivMacControlHelper::GetValue
  210. //----------------------------------------------------------------------------------------
  211.  
  212. inline short FW_CPrivMacControlHelper::GetValue() const
  213. {
  214.     return ::GetControlValue(fControlHandle);
  215. }
  216.  
  217. //----------------------------------------------------------------------------------------
  218. // FW_CPrivMacControlHelper::GetMin
  219. //----------------------------------------------------------------------------------------
  220.  
  221. inline short FW_CPrivMacControlHelper::GetMin() const
  222. {
  223.     return ::GetControlMinimum(fControlHandle);
  224. }
  225.  
  226. //----------------------------------------------------------------------------------------
  227. // FW_CPrivMacControlHelper::GetMax
  228. //----------------------------------------------------------------------------------------
  229.  
  230. inline short FW_CPrivMacControlHelper::GetMax() const
  231. {
  232.     return ::GetControlMaximum(fControlHandle);
  233. }
  234.  
  235. //----------------------------------------------------------------------------------------
  236. // FW_CPrivMacControlHelper::GetControl
  237. //----------------------------------------------------------------------------------------
  238.  
  239. inline FW_CNativeControl* FW_CPrivMacControlHelper::GetControl() const
  240. {
  241.     return fControl;
  242. }
  243.  
  244. //----------------------------------------------------------------------------------------
  245. // FW_CPrivMacControlHelper::SetControlMargin
  246. //----------------------------------------------------------------------------------------
  247.  
  248. inline void FW_CPrivMacControlHelper::SetControlMargin(short controlMargin)
  249. {
  250.     fControlMargin = controlMargin;
  251. }
  252.  
  253. #endif
  254.